package com.sxl.chapter.three;

import com.sxl.chapter.four.MintoringTest;

public class Eden extends MintoringTest{

	private static final int _1MB = 1024*1024;
	
	/**
	 * VM args : -verbose:gc -Xms20m -Xmx20m -Xmn10m -XX:SurvivorRatio=8 
	 * -XX:+PrintGCDetails
	 */
	private static void testAllocation () {
		
		byte[] allcation1,allcation2,allcation3,allcation4;
		allcation1 = new byte[2 * _1MB];
		allcation2 = new byte[2 * _1MB];
		allcation3 = new byte[2 * _1MB];
		allcation4 = new byte[4 * _1MB];
		
	}
	
	/**
	 * VM args : -verbose:gc -Xms20m -Xmx20m -Xmn10m -XX:SurvivorRatio=8 
	 * -XX:PretenureSizeThreshold=3145728
	 * -XX:+PrintGCDetails
	 */
	private static void testPretenureSizeThreshold() {
		
		byte[] allocation = new byte[4 * _1MB];
	}
	
	
	/**
	 * VM args : -verbose:gc -Xms20m -Xmx20m -Xmn10m -XX:SurvivorRatio=8 
	 * -XX:MaxTenuringThreshold=1
	 * -XX:+PrintTenuringDistribution
	 * -XX:+PrintGCDetails
	 */
	private static void testTenuringThreshold() {
		
		byte[] allcation1,allcation2,allcation3,allcation4;
		allcation1 = new byte[_1MB/4];
		allcation2 = new byte[4 * _1MB];
		allcation3 = new byte[4 * _1MB];
		allcation3 = null;
		allcation3 = new byte[4 * _1MB];
		
	}
	
	/**
	 * VM args : -verbose:gc -Xms20m -Xmx20m -Xmn10m -XX:SurvivorRatio=8 
	 * -XX:MaxTenuringThreshold=15
	 * -XX:+PrintTenuringDistribution
	 * -XX:+PrintGCDetails
	 */
	private static void testTenuringThreshold2() {
		
		byte[] allcation1,allcation2,allcation3,allcation4;
		allcation1 = new byte[_1MB/4];
		allcation4 = new byte[_1MB/8];
		allcation2 = new byte[4 * _1MB];
		allcation3 = new byte[4 * _1MB];
		allcation3 = null;
		allcation3 = new byte[4 * _1MB];
		
	}
	/**
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
//		testPretenureSizeThreshold();
//		testTenuringThreshold();
		testTenuringThreshold2();
		Eden e = new Eden();
	}
	
	public float add(int a, float b) {
		
		return a+b;
	}
	
}
